Skip to content

Conversation

DougGregor
Copy link
Member

Asynchronous functions isolated to global actors hop to the global at
the beginning of the function but do not hop back on return. For
MainActor.run, this means that we would not "hop back" off the main
actor after executing the closure, which lead to too much code running
on the main thread. Dropping the "async" ensures that we hop back.
While we my also want the general "hop back" semantics for
asynchronous actor-isolated functions, for now this addresses the
problem with MainActor.run.

Fixes rdar://82138050.

Asynchronous functions isolated to global actors hop to the global at
the beginning of the function but do not hop back on return. For
`MainActor.run`, this means that we would not "hop back" off the main
actor after executing the closure, which lead to too much code running
on the main thread. Dropping the "async" ensures that we hop back.
While we my also want the general "hop back" semantics for
asynchronous actor-isolated functions, for now this addresses the
problem with `MainActor.run`.

Fixes rdar://82138050.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 48eab6d into swiftlang:main Oct 23, 2021
@DougGregor DougGregor deleted the mainactor-run-hop-back branch October 23, 2021 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants